jQuery(document).ready(function(){
	AnimateFunc.scrollMenu();
	AnimateFunc.slider();
	AnimateFunc.loadImg();


	ActFunc.selectPartyType();
	ActFunc.ajaxLoad();
});

var opt = {
	posX: 0,
	posY: 0,
	flag: false
}


var AnimateFunc = {
	scrollMenu: function(){
		jQuery(window).scroll(function(){
			opt.posX = jQuery(window).scrollTop();
			if(opt.posX >= 100){
				jQuery('#menu').addClass('scroll');
			}else{
				jQuery('#menu').removeClass('scroll');
			}
		});
	},
	slider: function(){
		jQuery(".rslides1,.rslides2").responsiveSlides({
	        speed: 1000
	    });
	},
	loadImg: function(){
		if(jQuery('.experience-detail').length){
			jQuery("img.lazy").lazyload({data_attribute: "orig",effect : "fadeIn" });
		}
	}
}


var ActFunc = {
	selectPartyType: function(){

		jQuery('.selectEvent').bind('mouseover',function(){
			opt.flag = false;
		});
		jQuery('.selectEvent').bind('mouseout',function(){
			opt.flag = true;
		});
		jQuery('.selectEvent').bind('click',function(){
			$this = jQuery(this);
			if($this.hasClass('show')){
				jQuery('.listSelect').hide();
				$this.removeClass('show');
			}else{
				jQuery('.listSelect').show();
				$this.addClass('show');
			}
		});
		jQuery('html').bind('click',function(){
			if(opt.flag == true){
				jQuery('.listSelect').hide();
				jQuery('.selectEvent').removeClass('show');
			}
		});

		jQuery('.listSelect li a').bind('click',function(){
			
			$this = jQuery(this);
			var val = [];
			var eventType = $this.attr('data-event');
			var text = $this.text();
			val.push(eventType,text);
			var el = $this.parents('form').find('select');
			el.find('option[value='+val[0]+']').attr('selected','selected');
			jQuery('.selectEvent span.datatext').text(val[1]);
			jQuery('.selectEvent').click();
			return false;
		})
	},
	ajaxLoad: function(){
		var el = jQuery("ul.experdata li a");
		el.bind('click',function(e){
			var tempDiv = '<div />';
			jQuery(tempDiv).addClass('temp').appendTo('body').hide();
			jQuery('.loading').show();
			$this = jQuery(this);
			var url = $this.attr('href');
			jQuery('html,body').animate({
				scrollTop:  jQuery('#content').offset().top,
			});


			setTimeout(function () {
				jQuery.ajax({url:url,
					success: function(data){
						//result = jQuery(data).filter('#result');
						var result = jQuery('div.temp').append(data).find('#content').html();
						jQuery('#content').html(result).scrollTop();
						jQuery('.loading').fadeOut(500);
						jQuery('div.temp').remove();
					}
				});
			},1000);


			if(url!=window.location){
				window.history.pushState({path:url},'',url);
			}
			return false;
		});

		jQuery(window).bind("popstate", function() {
		    link = location.pathname.replace(/^.*[\\/]/, ""); // get filename only
		    window.location.replace(link);
		});
	}
}



































